//1:输入两个字符串，查找第一个字符串在第二个字符串中出现的次数
//比如输入dog和 This is a good dog.则出现了一次。
public class Str {
    public static void main(String[] args) {
        String a1 = "dog";
        String a2 = "This is a good dog";
        int i = 0, b = 0;
        while ((b = a2.indexOf(a1, b)) > 0) {
            b += a1.length();
            i++;
        }
        System.out.println("出现了" + i + "次");
    }
}